var express = require('express');
var router = express.Router();
var MongoClient = require('mongodb').MongoClient;
const DB_CONN_STR = 'mongodb://localhost:27017';

router.post('/getData', function(req, res, next) {
    var data = req.body;
    MongoClient.connect(DB_CONN_STR, (err, client) => {
        if (err) console.log(err);
        var db = client.db('vue-cms');
        var conn = db.collection('help');
        var result = conn.find().toArray();
        result.then(function(val) {
            console.log(val);
            res.send({ msg: val });
            // res.rediret('/')
        }).catch(function(val) {
            console.log(val);
        });
    });
});
module.exports = router;